<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
	return view('welcome');
});

Route::get('/test', function () {
	return 'hahaha';
});

//载入视图
//Route::get('/user/login', function () {
//	return view('admin/login');
//});

//控制器中 的方法
Route::get('/user/lst','Admin\UserController@lst');

//test 控制器
Route::get('/test/lst','Admin\TestController@lst');


Route::get('/test/test','Admin\TestController@test');
Route::get('/test/del','Admin\TestController@del');
Route::get('/test/play','Admin\TestController@play');

//登录表单
Route::match(['get','post'],'/admin/login','Admin\AdminController@login');

Route::group( ['middleware'=> 'admin.login'], function (){

        Route::get('/admin/index',function(){
            return view('admin.index');
        });

//退出登录
        Route::get('/admin/logout',function(){
            //清空session
            session()->flush();
            return redirect('admin/login');
        });
    Route::get('/index/head',function (){
        return view('admin.head');
    });
    Route::get('/index/left',function(){
        return view('admin/left');
    });
    Route::get('/index/right',function(){
        return view('admin/right');
    });
});

//生成验证码
Route::get('/admin/code/{number?}', 'Admin\AdminController@code');
//添加用户
Route::match(['get','post'], '/admin/user/add','Admin\UserController@add');
//展示用户U列表
Route::match(['get','post'], '/admin/user/lst','Admin\UserController@lst');

//删除用户
Route::get( '/admin/user/del/{id?}','Admin\UserController@del')->where('id','[0-9]+');

//更新用户
Route::get( '/admin/user/edt/{id?}','Admin\UserController@edt');
Route::post( '/admin/user/edt','Admin\UserController@edt');

//Demo控制器

Route::get('/admin/demo/lst','Admin\DemoController@lst');
Route::match(['get','post'],'/admin/demo/add','Admin\DemoController@add');
Route::get('/admin/demo/del/{id?}','Admin\DemoController@del');

Route::get('/admin/demo/edt/{id?}','Admin\DemoController@edt');
Route::post('/admin/demo/edt','Admin\DemoController@edt');